import { IUser } from "../type/User";
import { useUserStore } from "../store/modules/User";

const login = (user: IUser) => {
  return new Promise((resolve, reject) => {
    if (user.password && user.password) {
      const useStore = useUserStore();
      useStore.setUserInfo({
        username: user.username,
        password: user.password,
        token: 'token',
        roles: user.username === 'super' ? ['super'] : ['admin'],
      });
      resolve({
        msg: 'success',
      })
    };
    reject({
      msg: 'fail'
    });
  })
};
const UserService = {
  login
};
export default UserService;